#include "mysocket.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

int socket_init()
{
    int server_fd;
    int ret;
    struct sockaddr_in server;
    memset (&server, 0, sizeof(struct sockaddr_in));
    server_fd = socket (AF_INET, SOCK_STREAM, 0);
    if (server_fd == -1)
    {
        perror("socket");
        return -1;
    }
    server.sin_family = AF_INET;
    server.sin_port = htons (atoi("8199"));
    inet_aton ("192.168.1.23", &server.sin_addr);
    ret = bind (server_fd, (struct sockaddr *)&server, sizeof(struct sockaddr_in));
    if (-1 == ret)
    {
        perror("bind");
        return -1;
    }
    ret = listen (server_fd, 1);
    if (-1 == ret)
    {
        perror("listen");
        return -1;
    }
    return server_fd;
}